package com.hemerasolutions.v2trainer.converter;

import java.io.Serializable;

import javax.faces.convert.FacesConverter;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.NumberConverter;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("request")
@FacesConverter("dynamicNumberConverter")
public class DynamicNumberConverter extends NumberConverter implements Serializable{

	private static final long serialVersionUID = 1L;

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
//        setPattern((String) component.getAttributes().get("pattern"));

    	setMaxFractionDigits(12);	
    	return super.getAsObject(context, component, value);
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
//        setPattern((String) component.getAttributes().get("pattern"));
    	setMaxFractionDigits(12);	

    	return super.getAsString(context, component, value);
    }
}

